<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="stylesheet" type="text/css" href="${jpath}/assets/public/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="${jpath}/assets/public/font-awesome/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="${jpath}/demo/css/animate.css"/>
    <link rel="stylesheet" type="text/css" href="${jpath}/demo/css/style.css?v=${version}""/>
    <link rel="stylesheet" type="text/css" href="${jpath}/demo/css/login.css?v=${version}""/>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
    [#assign captchaId=statics.UUID.randomUUID()/]
</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-12">
            <form method="post" action="${base}/m/login" id="loginForm">
                <h4 class="no-margins">登录：</h4>
                <p class="m-t-md">登录到360汇云后台</p>
                <input type="hidden" id="enPassword" name="enPassword"/>
                <input type="hidden" name="captchaId" value="${captchaId}" />

                <input  name="username" id="username"  class="form-control uname" placeholder="用户名" />
                <input name="password" id="password"   type="password" class="form-control pword m-b" placeholder="密码" />
                <div class="row m-b">
                    <div class="col-sm-8">
                        <input name="captcha" id="captcha" maxlength="4" autocomplete="off" class="form-control"  style="margin-top:0px;"  placeholder="填写右侧的验证码" />
                    </div>
                    <div class="col-sm-4" style="padding-left:0px;">
                        <img id="captchaImage"  src="${base}/captcha?captchaId=${captchaId}" title="${message("admin.captcha.imageTitle")}"/>
                    </div>
                </div>
                <a href="${base}/normal/retrievePassword/index" id="forget-password">忘记密码了？</a>
                <button type="submit" class="btn btn-success btn-block">登录</button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; hAdmin
        </div>
    </div>
</div>


<script type="text/javascript" src="${jpath}/assets/public/js/jquery.min.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/plugins/jquery.lazyload.min.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/plugins/jquery-validation/jquery.validate.min.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/jsbn.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/prng4.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/rng.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/rsa.js"></script>
<script type="text/javascript" src="${jpath}/assets/public/js/base64.js"></script>
<script type="text/javascript">
    $(function () {
        var $loginForm = $("#loginForm");
        var $enPassword = $("#enPassword");
        var $username = $("#username");
        var $password = $("#password");
        var $captcha = $("#captcha");
        var $captchaImage = $("#captchaImage");
        var $isRememberUsername = $("#isRememberUsername");
        var $errorMessage = $("#error_message");

        // 更换验证码
        $captchaImage.click(function () {
            $captchaImage.attr("src", "${base}/captcha?captchaId=${captchaId}&timestamp=" + (new Date()).valueOf());
        });

        // 表单验证、记住用户名
        $loginForm.submit(function () {
            if ($username.val() == "") {
                $errorMessage.show().text("${message("admin.login.usernameRequired")}");
                return false;
            }
            if ($password.val() == "") {
                $errorMessage.show().text("${message("admin.login.passwordRequired")}");
                return false;
            }
            if ($captcha.val() == "") {
                $errorMessage.show().removeClass("").text("验证码不能为空");
                return false;
            }
            var rsaKey = new RSAKey();
            rsaKey.setPublic(b64tohex("${modulus}"), b64tohex("${exponent}"));
            var enPassword = hex2b64(rsaKey.encrypt($password.val()));
            $enPassword.val(enPassword);
        });

        if ("${loginErrorMessage}") {
            $errorMessage.show().text("${loginErrorMessage}");
        } else {
            $errorMessage.hide();
        }
    });

</script>

</body>

</html>
